package com.pj.service.impl;

import com.pj.bean.BrandInfo;
import com.pj.respository.BrandInfoRepository;
import com.pj.service.ElasticSearchService;
import org.dromara.easyes.core.biz.EsPageInfo;
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
import org.dromara.easyes.core.kernel.EsWrappers;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ElasticSearchServiceImpl implements ElasticSearchService {

    @Resource
    private BrandInfoRepository brandInfoRepository;

    @Override
    public List<BrandInfo> getBrandAll(String name) {
        LambdaEsQueryWrapper<BrandInfo> eq = EsWrappers.lambdaQuery(BrandInfo.class).eq(BrandInfo::getBrandName, name);
        return brandInfoRepository.selectList(eq);
    }

    @Override
    public EsPageInfo<BrandInfo> getBrandAllByPage(int pageNum, int pageSize) {
        LambdaEsQueryWrapper<BrandInfo> lambdaQuery = EsWrappers.lambdaQuery(BrandInfo.class);
        return brandInfoRepository.pageQuery(lambdaQuery, pageNum, pageSize);
    }
}
